﻿using System;

namespace Borg
{
    [Serializable]
    public class TagEventArgs : EventArgs
    {
        private readonly Slot _slot;
        private readonly Plug _plug;

        private readonly string _name;
        private readonly Tag _tag;

        public Slot Slot
        {
            get { return _slot; }
        }

        public Plug Plug
        {
            get { return _plug; }
        }

        public string Name
        {
            get { return _name; }
        }

        public Tag Tag
        {
            get { return _tag; }
        }

        public TagEventArgs(Slot slot, Plug plug, string name)
        {
            _slot = slot;
            _plug = plug;
            _name = name;
        }

        public TagEventArgs(Tag tag)
            : this(tag.Slot, tag.Plug, tag.Name)
        {
            _tag = tag;
        }

        public override bool Equals(object obj)
        {
            if (obj == this)
                return true;

            if (!(obj is TagEventArgs))
                return false;

            var tagEventArgs = (TagEventArgs)obj;
            
            return
                Equals(_slot, tagEventArgs._slot) &&
                Equals(_plug, tagEventArgs._plug) &&
                Equals(_name, tagEventArgs._name);
        }

        public override int GetHashCode()
        {
            return
                _slot.GetHashCode() ^
                _plug.GetHashCode() ^
                _name.GetHashCode();
        }
    }
}
